package display;

import java.awt.Graphics;
import java.util.Observable;
import java.util.Observer;

import javax.swing.JPanel;

import universe.Board;

@SuppressWarnings("serial")
public class BoardDisplay extends JPanel{

	Board board;	
	
	public BoardDisplay(Board pBoard){
		super();
		this.board = pBoard;
		
		System.out.println("constructeur de BoardDisplay");
		this.setSize(display.Utils.getBoardWidthPx(), display.Utils.getBoardHeightPx());
		//this.setBackground(Color.GREEN);
		//System.out.println("size of board "+this.getSize());
	}
		
		
	public void paintComponent(Graphics g){
		int[][] matrix = board.getMatrix();
		for(int i=0; i<board.getWidth();i++){
			for(int j=0; j<board.getHeight();j++){
				g.setColor(Utils.getColor(matrix[i][j]));
				g.fillRect(i*Utils.sideWidth, j*Utils.sideWidth, Utils.sideWidth, Utils.sideWidth);
			}
		}	
	}

}
